﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using SevenWizards1.CoreComponents;
namespace SevenWizards1
{
    class PopUpScreen : GameScreen
    {
        ButtonMenu menu;
        Texture2D image;
        SpriteBatch spriteBatch;
        Rectangle imageRectangle;

        public PopUpScreen(Game game, SpriteFont spriteFont, Texture2D image,
            Texture2D buttonImage)
            : base(game)
        {
            this.image = image;
            spriteBatch =
                (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));
            imageRectangle = new Rectangle();
            imageRectangle.X = (game.Window.ClientBounds.Width - image.Width) / 2;
            imageRectangle.Y =
                (game.Window.ClientBounds.Height - image.Height) / 2;
            imageRectangle.Width = image.Width;
            imageRectangle.Height = image.Height;

            string[] items = { "YES", "NO" };
            menu = new ButtonMenu(game, spriteFont, buttonImage);
            menu.SetMenuItems(items);
            Components.Add(menu);
        }

        public int SelectedIndex
        {
            get { return menu.SelectedIndex; }
        }

        public void SetMenuItems(string[] items)
        {
            menu.SetMenuItems(items);
        }

        public override void Draw(GameTime gameTime)
        {
            spriteBatch.Draw(image, imageRectangle, Color.White);
            base.Draw(gameTime);
        }

        public override void Show()
        {
            base.Show();
            menu.Position = new Vector2((imageRectangle.Width -
                                menu.Width) / 2 + imageRectangle.X,
                                imageRectangle.Height - menu.Height - 10 +
                                    imageRectangle.Y);
        }
    }
}